<div class="container-fluid">
    <div class="wrapper">
        <div class="panel" id="nav">
            <div class="panel-heading"><h3 class="panel-title">盘点库存</h3></div>
            <div class="panel-body">
                <form action="" method="get">
                    <div class="container-fluid">
                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">库位搜索</span>
                                <input type="text" name="storage_position" class="form-control" value="">
                            </div>
                        </div>
                        <!--<div class="clearfix"></div>-->
                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">SKU</span>
                                <input type="text" name="sku" class="form-control" value="">
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">站点</span>
                                <select class="chosen-select form-control" tabindex="-1" name="site_id" data-name-group="common">
                                    <option value="" class="empty-opt">-- 请选择 --</option>
                                    <volist name="sites" id="item">
                                        <option value="{$key}">{$item}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-3  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">截止日期</span>
                                <input class="form-control form-date" type="text" name="warehouse_date_to"
                                       style="cursor:pointer;" readonly>
                            </div>
                        </div>
                        <div class="col-md-4 add-space">
                            <input class="btn btn-primary" type="submit" value="查询">
                            <input class="btn btn-success" type="button" onclick="download_csv()" value="查询结果下载">
                        </div>


                    </div>
                </form>
                <div class="clearfix"></div>
                <hr>

                <table class="table table-striped  table-hover" cellspacing="0" width="100%">
                    <thead>
                    <tr>
                        <!--<th width="20"><input id="checkAll" type="checkbox"></th>-->
                        <th>SKU</th>
                        <th>中文名称</th>
                        <th>储位</th>
                        <th>站点</th>
                        <th>实际库存量</th>
                        <th>是否出口退税</th>
                        <th>公司主体</th>
                        <th>销售状态</th>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="result" id="val">
                        <tr>
                            <td>{$val.sku}</td>
                            <td>{$val.sku_name}</td>
                            <td>{$val.storage_position}</td>
                            <td>{$val.site_id}</td>
                            <td>{$val.all_available_quantity}</td>
                            <td>{$val.export_tax_rebate}</td>
                            <td>{$val.enterprise_dominant}</td>
                            <td>{$val.status}</td>
                        </tr>
                    </volist>

                </table>
                <div class="row">
                    <div class="col-md-6 pull-left">
                        <label>每页 15 条记录
                            显示 1 到 15 项，共 {$count}项</label>
                    </div>
                    <div class="col-md-6">
                        <div class="page pull-right" style="padding: 0;margin: 0">
                            {$page}
                        </div>
                    </div>
                </div>
                <hr>
                <h3><span class="text-danger">库存盘点批量上传:</span></h3>
                <form action="__URL__/upload"  method="post" enctype="multipart/form-data" class="form-horizontal">
                    <div class="form-group">
                        <label class="col-md-3 control-label required">批量上传</label>
                        <div class="col-md-3">
                            <!--<input type="file" name="file" class="form-control">-->
                            <input class="btn" type="file" name="file" value="" style="width: 100%"/>
                        </div>
                        <div class="col-md-2"><p style="padding-top: 5px;">支持xls/xlsx格式</p></div>
                        <div class="col-md-2">
                            <input type="hidden" name="insert" value="insert">
                            <button class="btn btn-info" type="submit" >上传</button>
                            <button class="btn btn-info" type="button" onclick="down_template()">下载模板</button>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label"></label>
                        <div class="col-md-3">
                            <span id="tip"></span>
                        </div>

                    </div>
                </form>
                <div>
                    <?php if(!isset($result)) echo $result;?>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("input[name='sku']").val("<?php echo $_GET['sku'];?>");
        $("input[name='storage_position']").val("<?php  echo $_GET['storage_position'];?>");
        $("input[name='warehouse_date_to']").val("<?php echo $_GET['warehouse_date_to'];?>");
        $("select[name='site_id']").val("<?php echo $_GET['site_id'];?>");
    });
    /**
     * 下载模板
     */
    function down_template() {
        window.location.href ='__URL__/down_template';
    }

    /**
     * @returns {string}
     * 获取搜索条件
     * khq 2017.3.2
     */
    function search_params(){
        var param = '';
        var storage_position = $("input[name='storage_position']").val();
        var sku = $("input[name='sku']").val();
        var warehouse_date_to = $("input[name='warehouse_date_to']").val();

        if($.trim(storage_position) != ''){
            param += "&storage_position="+$.trim(storage_position);
        }
        if($.trim(sku) != ''){
            param += "&sku="+$.trim(sku);
        }
        if($.trim(warehouse_date_to) != '') {
            param += "&warehouse_date_to="+$.trim(warehouse_date_to);
        }
        return param;
    }
    function download_csv() {
        var param = search_params();
        window.location.href = '__URL__/pandian?downcsv=1' + param;
    }
</script>





